<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class User_association_model extends CI_Model
{
    private $_table = 'sm_user_association';

    public function __construct()
    {
        parent::__construct();
    }

    public function addUserAssociaton($insertAssociationData = array())
    {
        $this->db->insert($this->_table, $insertAssociationData);
        $last = $this->db->insert_id();
        return $last;
    }

    public function updateUserAssociaton($where, $updateAssociationData = array())
    {
        if (isset($where) && count($where) > 0) {
            foreach ($where as $key => $val) {
                $condition = array (
                    $key => $val
                );
                $this->db->where($condition);
            }
        }

        $result = $this->db->update($this->_table, $updateAssociationData);
        return $result;
    }

    function getAll()
    {
        $this->db->select("*");
        $query = $this->db->get($this->_table);
        return $query->result_array();
    }

}